<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var maxVowels = function (s, k) {
      let hash = new Set(['a', 'e', 'i', 'o', 'u'])
      let n = s.length;
      let left = 0, right = 0
      let count = 0
      while (right < k) {
        hash.has(s[right++]) && count++
      }
      let res = count
      while (right < n) {
        hash.has(s[right++]) && count++
        hash.has(s[left++]) && count--
        res = Math.max(res, count);
      }
      return res
    };
    console.log(maxVowels("rhythms", 4));
  </script>
</body>

</html>